package com.lwj.liwanjia.adapter;

import android.content.Context;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.bumptech.glide.Glide;
import com.lwj.liwanjia.R;
import com.lwj.liwanjia.bean.YongHuFanKuiHomeBean;

import java.util.List;

import de.hdodenhof.circleimageview.CircleImageView;

/**
 * Created by 001 on 2017/9/13.
 */

public class YongHuFanKuiHomeAdapter extends RecyclerView.Adapter<YongHuFanKuiHomeAdapter.ViewHolder> {

    private Context mContext;
    private List<YongHuFanKuiHomeBean> mList;

    public YongHuFanKuiHomeAdapter(Context mContext,List<YongHuFanKuiHomeBean> mList) {
        this.mContext = mContext;
        this.mList = mList;

    }

    @Override
    public YongHuFanKuiHomeAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        View view = LayoutInflater.from(mContext).inflate(R.layout.adapter_yong_hu_fan_kui_home, parent, false);

        ViewHolder holder = new ViewHolder(view);

        return holder;
    }

    @Override
    public void onBindViewHolder(YongHuFanKuiHomeAdapter.ViewHolder holder, int position) {

        YongHuFanKuiHomeBean bean = mList.get(position);

        Glide.with(mContext).load(bean.url).into(holder.circle_photo);

    }

    @Override
    public int getItemCount() {
        return mList.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {

        CircleImageView circle_photo;

        public ViewHolder(View itemView) {
            super(itemView);

            circle_photo = (CircleImageView) itemView.findViewById(R.id.circle_photo);
        }
    }
}
